///-----------------------------------------------------------------
///
/// @file      CreateProjectFrm.cpp
/// @author    -
/// Created:   10.04.2014 22:34:13
/// @section   DESCRIPTION
///            CreateProjectFrm class implementation
///
///------------------------------------------------------------------

#include "CreateProjectFrm.h"
#include "D-DrawFrm.h"
#include "GuiCommandProcessor\File_New_GuiCommand.h"
#include "GuiCommandProcessor\GuiCommandProcessor.h"
#include "ProjectManagement\ProjectManager.h"

//Do not add custom headers between
//Header Include Start and Header Include End
//wxDev-C++ designer will remove them
////Header Include Start
////Header Include End

//----------------------------------------------------------------------------
// CreateProjectFrm
//----------------------------------------------------------------------------
//Add Custom Events only in the appropriate block.
//Code added in other places will be removed by wxDev-C++
////Event Table Start
BEGIN_EVENT_TABLE(CreateProjectFrm,wxFrame)
	////Manual Code Start
	////Manual Code End
	
	EVT_CLOSE(CreateProjectFrm::OnClose)
	EVT_BUTTON(ID_WXBUTTON2,CreateProjectFrm::WxButton2Click)
	EVT_BUTTON(ID_WXBUTTON1,CreateProjectFrm::WxButton1Click)
END_EVENT_TABLE()
////Event Table End

CreateProjectFrm::CreateProjectFrm(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
	CreateGUIControls();
}

CreateProjectFrm::~CreateProjectFrm()
{
}

void CreateProjectFrm::CreateGUIControls()
{
	//Do not add custom code between
	//GUI Items Creation Start and GUI Items Creation End
	//wxDev-C++ designer will remove them.
	//Add the custom code before or after the blocks
	////GUI Items Creation Start

	WxPanel1 = new wxPanel(this, ID_WXPANEL1, wxPoint(0, 0), wxSize(484, 201));

	WxStaticBox1 = new wxStaticBox(WxPanel1, ID_WXSTATICBOX1, wxT("Enter project details"), wxPoint(8, 12), wxSize(452, 103));

	WxButton1 = new wxButton(WxPanel1, ID_WXBUTTON1, wxT("OK"), wxPoint(43, 125), wxSize(110, 31), 0, wxDefaultValidator, wxT("WxButton1"));

	WxButton2 = new wxButton(WxPanel1, ID_WXBUTTON2, wxT("CANCEL"), wxPoint(286, 124), wxSize(110, 31), 0, wxDefaultValidator, wxT("WxButton2"));

	WxStaticText1 = new wxStaticText(WxPanel1, ID_WXSTATICTEXT1, wxT("Name:"), wxPoint(16, 42), wxDefaultSize, 0, wxT("WxStaticText1"));

	WxEdit1 = new wxTextCtrl(WxPanel1, ID_WXEDIT1, wxT("Untitled"), wxPoint(60, 39), wxSize(202, 22), 0, wxDefaultValidator, wxT("WxEdit1"));
	WxEdit1->SetMaxLength(256);

	SetTitle(wxT("Create new project"));
	SetIcon(wxNullIcon);
	SetSize(8,8,484,201);
	Center();
	
	////GUI Items Creation End
}

void CreateProjectFrm::OnClose(wxCloseEvent& event)
{
	Destroy();
}

/*
 * WxButton1Click
 */
void CreateProjectFrm::WxButton1Click(wxCommandEvent& event)
{
	// insert your code here
	wxString project_name = WxEdit1->GetValue();
	wxWindow* parent=this->GetParent();
	ProjectManager* project_manager = ((D_DrawFrm*)parent)->GetProjectManager();
	
	File_New_GuiCommand* gui_command=new File_New_GuiCommand((void*)project_manager, project_name);
	((D_DrawFrm*)parent)->GetCommandProcessor()->ExecuteCommand(gui_command);	
	parent->Enable();
	Destroy();
}

/*
 * WxButton2Click
 */
void CreateProjectFrm::WxButton2Click(wxCommandEvent& event)
{
	// insert your code here
	this->GetParent()->Enable();
	Destroy();
}
